/*
 * 
 * 
 * 
 */
package com.cms.controller.front;

import com.cms.entity.Category;
import com.cms.entity.Content;
import com.cms.entity.PushContent;
import com.cms.interceptor.SiteInterceptor;
import com.cms.routes.RouteMapping;
import com.jfinal.aop.Before;

import java.util.List;

/**
 * Controller - 内容
 * 
 * 
 * 
 */
@RouteMapping(url = "/pushContent")
@Before(SiteInterceptor.class)
public class PushContentController extends BaseController {
	 public void index() {
	        Long pushContentId = getParaToLong(0);
	        PushContent pushContent = new PushContent().dao().findById(pushContentId);
	        List<PushContent> after = new PushContent().dao().find("select * from cms_push_content where categoryId = " + pushContent.getCategoryId() + " and id <" + pushContentId + " order by id desc limit 0,1");
	        List<PushContent> before = new PushContent().dao().find("select * from cms_push_content where categoryId = " + pushContent.getCategoryId() + " and id >" + pushContentId + " order by id limit 0,1");
	        setAttr("after", after);
	        setAttr("before", before);
	        setAttr("category", new Category().dao().findById(pushContent.getCategoryId()));
	        setAttr("currentContent", pushContent);
	        render("/templates/" + getTheme(getCurrentSite().getId()) + "/" + pushContent.getCategory().getContentTemplate());
	    }
	/**
	 * 内容
	 */
	/*public void index() {
		Long contentId = getParaToLong(0);
		Content content = new Content().dao().findById(contentId);
		setAttr("currentContent", content);
		render("/templates/"+getTheme(getCurrentSite().getId())+"/"+content.getCategory().getContentTemplate());
	}*/

}